/*
 * 
 *  This file is part of Sourceprojects.org Thracia.
 *  Copyright 2010 noctarius
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 * 
 */
package org.sourceprojects;

import org.sourceprojects.thracia.ReporterConfig;
import org.sourceprojects.thracia.impl.XmlBugReporter;
import org.sourceprojects.thracia.interfaces.VersionRetriever;

/**
 * @author noctarius
 * 
 */
public class TestWriter implements VersionRetriever {

	private class Foo extends Thread {
		private void deeperRun(int deep) {
			if (deep == 2) {
				System.out.print(1 / 0);
			} else {
				deeperRun(deep + 1);
			}
		}

		@Override
		public void run() {
			try {
				deeperRun(0);
			} catch (ArithmeticException e) {
				throw new DeeperRunException(e);
			}
		}
	}

	private class Foo2 extends Thread {

		@SuppressWarnings("null")
		private void deeperRun(int deep) {
			if (deep == 4) {
				String lala = "lala";
				lala = null;

				lala.split(" ");
			} else {
				deeperRun(deep + 1);
			}
		}

		@Override
		public void run() {
			deeperRun(0);
		}
	}

	private class DeeperRunException extends RuntimeException {
		private static final long serialVersionUID = 1017221172968336998L;

		public DeeperRunException(Throwable e) {
			super(e);
		}
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new TestWriter();
	}

	private TestWriter() {
		final ReporterConfig config = new ReporterConfig(this, this.getClass(),
				"org/sourceprojects/jbugreporter/config.xml");
		config.setReportdir("./");

		Thread.setDefaultUncaughtExceptionHandler(new XmlBugReporter(config));

		final Thread foo = new Foo();
		foo.start();
		final Thread foo2 = new Foo2();
		foo2.start();
		final Thread foo3 = new Foo2();
		foo3.start();
	}

	public String getVersionNumber() {
		return "1.1.0A";
	}

	public String getProductName() {
		return "jBugReporter Testsystem";
	}
}
